<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * @class The built-in Date class.
<span class='line'>  3</span>  * @name Date
<span class='line'>  4</span>  */</span><span class="WHIT">
<span class='line'>  5</span> 
<span class='line'>  6</span> </span><span class="NAME">Date.__parse__</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Date.parse</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  7</span> 
<span class='line'>  8</span> </span><span class="COMM">/**
<span class='line'>  9</span>  * Parses a date from a string, optionally using the specified formatting. If
<span class='line'> 10</span>  * only a single argument is specified (i.e., &lt;tt>format&lt;/tt> is not specified),
<span class='line'> 11</span>  * this method invokes the native implementation to guarantee
<span class='line'> 12</span>  * backwards-compatibility.
<span class='line'> 13</span>  *
<span class='line'> 14</span>  * &lt;p>The format string is in the same format expected by the &lt;tt>strptime&lt;/tt>
<span class='line'> 15</span>  * function in C. The following conversion specifications are supported:&lt;ul>
<span class='line'> 16</span>  *
<span class='line'> 17</span>  * &lt;li>%b - abbreviated month names.&lt;/li>
<span class='line'> 18</span>  * &lt;li>%B - full month names.&lt;/li>
<span class='line'> 19</span>  * &lt;li>%h - same as %b.&lt;/li>
<span class='line'> 20</span>  * &lt;li>%d - day of month [1,31].&lt;/li>
<span class='line'> 21</span>  * &lt;li>%e - same as %d.&lt;/li>
<span class='line'> 22</span>  * &lt;li>%H - hour (24-hour clock) [0,23].&lt;/li>
<span class='line'> 23</span>  * &lt;li>%m - month number [1,12].&lt;/li>
<span class='line'> 24</span>  * &lt;li>%M - minute [0,59].&lt;/li>
<span class='line'> 25</span>  * &lt;li>%S - second [0,61].&lt;/li>
<span class='line'> 26</span>  * &lt;li>%y - year with century [0,99].&lt;/li>
<span class='line'> 27</span>  * &lt;li>%Y - year including century.&lt;/li>
<span class='line'> 28</span>  * &lt;li>%% - %.&lt;/li>
<span class='line'> 29</span>  *
<span class='line'> 30</span>  * &lt;/ul>The following conversion specifications are &lt;i>unsupported&lt;/i> (for now):&lt;ul>
<span class='line'> 31</span>  *
<span class='line'> 32</span>  * &lt;li>%a - day of week, either abbreviated or full name.&lt;/li>
<span class='line'> 33</span>  * &lt;li>%A - same as %a.&lt;/li>
<span class='line'> 34</span>  * &lt;li>%c - locale's appropriate date and time.&lt;/li>
<span class='line'> 35</span>  * &lt;li>%C - century number.&lt;/li>
<span class='line'> 36</span>  * &lt;li>%D - same as %m/%d/%y.&lt;/li>
<span class='line'> 37</span>  * &lt;li>%I - hour (12-hour clock) [1,12].&lt;/li>
<span class='line'> 38</span>  * &lt;li>%j - day number [1,366].&lt;/li>
<span class='line'> 39</span>  * &lt;li>%n - any white space.&lt;/li>
<span class='line'> 40</span>  * &lt;li>%p - locale's equivalent of a.m. or p.m.&lt;/li>
<span class='line'> 41</span>  * &lt;li>%r - same as %I:%M:%S %p.&lt;/li>
<span class='line'> 42</span>  * &lt;li>%R - same as %H:%M.&lt;/li>
<span class='line'> 43</span>  * &lt;li>%t - same as %n.&lt;/li>
<span class='line'> 44</span>  * &lt;li>%T - same as %H:%M:%S.&lt;/li>
<span class='line'> 45</span>  * &lt;li>%U - week number [0,53].&lt;/li>
<span class='line'> 46</span>  * &lt;li>%w - weekday [0,6].&lt;/li>
<span class='line'> 47</span>  * &lt;li>%W - week number [0,53].&lt;/li>
<span class='line'> 48</span>  * &lt;li>%x - locale's equivalent to %m/%d/%y.&lt;/li>
<span class='line'> 49</span>  * &lt;li>%X - locale's equivalent to %I:%M:%S %p.&lt;/li>
<span class='line'> 50</span>  *
<span class='line'> 51</span>  * &lt;/ul>
<span class='line'> 52</span>  *
<span class='line'> 53</span>  * @see &lt;a
<span class='line'> 54</span>  * href="http://www.opengroup.org/onlinepubs/007908799/xsh/strptime.html">strptime&lt;/a>
<span class='line'> 55</span>  * documentation.
<span class='line'> 56</span>  * @param {string} s the string to parse as a date.
<span class='line'> 57</span>  * @param {string} [format] an optional format string.
<span class='line'> 58</span>  * @returns {Date} the parsed date.
<span class='line'> 59</span>  */</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="NAME">Date.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">format</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Date.__parse__</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 64</span> 
<span class='line'> 65</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1970</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">date</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hour</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">minute</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">second</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fields</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">  </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format.replace</span><span class="PUNC">(</span><span class="REGX">/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"\\$&"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">  </span><span class="NAME">format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">format.replace</span><span class="PUNC">(</span><span class="REGX">/%[a-zA-Z0-9]/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">      </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %a: day of week, either abbreviated or full name</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %A: same as %a</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%b'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">                </span><span class="NAME">Jan</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Feb</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Mar</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Apr</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">May</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Jun</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Jul</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Aug</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">                </span><span class="NAME">Sep</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Oct</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Nov</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Dec</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">11</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">              </span><span class="PUNC">}</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"([A-Za-z]+)"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%h'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%B'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">                </span><span class="NAME">January</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">February</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">March</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">April</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">May</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">June</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">                </span><span class="NAME">July</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">6</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">August</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">7</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">September</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">October</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">November</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">                </span><span class="NAME">December</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">11</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">              </span><span class="PUNC">}</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"([A-Za-z]+)"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %c: locale's appropriate date and time</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %C: century number[0,99]</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%e'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%d'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">date</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"([0-9]+)"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %D: same as %m/%d/%y</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%H'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">hour</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"([0-9]+)"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %I: hour (12-hour clock) [1,12]</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %j: day number [1,366]</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%m'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">month</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"([0-9]+)"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%M'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">minute</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"([0-9]+)"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %n: any white space</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %p: locale's equivalent of a.m. or p.m.</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %r: %I:%M:%S %p</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %R: %H:%M</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%S'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">second</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"([0-9]+)"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %t: any white space</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %T: %H:%M:%S</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %U: week number [00,53]</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %w: weekday [0,6]</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %W: week number [00, 53]</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %x: locale date (%m/%d/%y)</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %X: locale time (%I:%M:%S %p)</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%y'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">              </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">              </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">69</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">2000</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">                  </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">69</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NUMB">1900</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"([0-9]+)"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%Y'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"([0-9]+)"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%%'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">          </span><span class="NAME">fields.push</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"%"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> 
<span class='line'>145</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">match</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="NAME">format</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">match</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">match.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">year</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">month</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">date</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">hour</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">minute</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">second</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>149</span> 
<span class='line'>150</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Date.prototype.toLocaleFormat</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">  </span><span class="NAME">Date.prototype.format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Date.prototype.toLocaleFormat</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>153</span> 
<span class='line'>154</span> </span><span class="COMM">/**
<span class='line'>155</span>  * Converts a date to a string using the specified formatting. If the
<span class='line'>156</span>  * &lt;tt>Date&lt;/tt> object already supports the &lt;tt>toLocaleFormat&lt;/tt> method, as
<span class='line'>157</span>  * in Firefox, this is simply an alias to the built-in method.
<span class='line'>158</span>  *
<span class='line'>159</span>  * &lt;p>The format string is in the same format expected by the &lt;tt>strftime&lt;/tt>
<span class='line'>160</span>  * function in C. The following conversion specifications are supported:&lt;ul>
<span class='line'>161</span>  *
<span class='line'>162</span>  * &lt;li>%a - abbreviated weekday name.&lt;/li>
<span class='line'>163</span>  * &lt;li>%A - full weekday name.&lt;/li>
<span class='line'>164</span>  * &lt;li>%b - abbreviated month names.&lt;/li>
<span class='line'>165</span>  * &lt;li>%B - full month names.&lt;/li>
<span class='line'>166</span>  * &lt;li>%c - locale's appropriate date and time.&lt;/li>
<span class='line'>167</span>  * &lt;li>%C - century number.&lt;/li>
<span class='line'>168</span>  * &lt;li>%d - day of month [01,31] (zero padded).&lt;/li>
<span class='line'>169</span>  * &lt;li>%D - same as %m/%d/%y.&lt;/li>
<span class='line'>170</span>  * &lt;li>%e - day of month [ 1,31] (space padded).&lt;/li>
<span class='line'>171</span>  * &lt;li>%h - same as %b.&lt;/li>
<span class='line'>172</span>  * &lt;li>%H - hour (24-hour clock) [00,23] (zero padded).&lt;/li>
<span class='line'>173</span>  * &lt;li>%I - hour (12-hour clock) [01,12] (zero padded).&lt;/li>
<span class='line'>174</span>  * &lt;li>%m - month number [01,12] (zero padded).&lt;/li>
<span class='line'>175</span>  * &lt;li>%M - minute [0,59] (zero padded).&lt;/li>
<span class='line'>176</span>  * &lt;li>%n - newline character.&lt;/li>
<span class='line'>177</span>  * &lt;li>%p - locale's equivalent of a.m. or p.m.&lt;/li>
<span class='line'>178</span>  * &lt;li>%r - same as %I:%M:%S %p.&lt;/li>
<span class='line'>179</span>  * &lt;li>%R - same as %H:%M.&lt;/li>
<span class='line'>180</span>  * &lt;li>%S - second [00,61] (zero padded).&lt;/li>
<span class='line'>181</span>  * &lt;li>%t - tab character.&lt;/li>
<span class='line'>182</span>  * &lt;li>%T - same as %H:%M:%S.&lt;/li>
<span class='line'>183</span>  * &lt;li>%x - same as %m/%d/%y.&lt;/li>
<span class='line'>184</span>  * &lt;li>%X - same as %I:%M:%S %p.&lt;/li>
<span class='line'>185</span>  * &lt;li>%y - year with century [00,99] (zero padded).&lt;/li>
<span class='line'>186</span>  * &lt;li>%Y - year including century.&lt;/li>
<span class='line'>187</span>  * &lt;li>%% - %.&lt;/li>
<span class='line'>188</span>  *
<span class='line'>189</span>  * &lt;/ul>The following conversion specifications are &lt;i>unsupported&lt;/i> (for now):&lt;ul>
<span class='line'>190</span>  *
<span class='line'>191</span>  * &lt;li>%j - day number [1,366].&lt;/li>
<span class='line'>192</span>  * &lt;li>%u - weekday number [1,7].&lt;/li>
<span class='line'>193</span>  * &lt;li>%U - week number [00,53].&lt;/li>
<span class='line'>194</span>  * &lt;li>%V - week number [01,53].&lt;/li>
<span class='line'>195</span>  * &lt;li>%w - weekday number [0,6].&lt;/li>
<span class='line'>196</span>  * &lt;li>%W - week number [00,53].&lt;/li>
<span class='line'>197</span>  * &lt;li>%Z - timezone name or abbreviation.&lt;/li>
<span class='line'>198</span>  *
<span class='line'>199</span>  * &lt;/ul>
<span class='line'>200</span>  *
<span class='line'>201</span>  * @see &lt;a
<span class='line'>202</span>  * href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date/toLocaleFormat">Date.toLocaleFormat&lt;/a>
<span class='line'>203</span>  * documentation.
<span class='line'>204</span>  * @see &lt;a
<span class='line'>205</span>  * href="http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html">strftime&lt;/a>
<span class='line'>206</span>  * documentation.
<span class='line'>207</span>  * @param {string} format a format string.
<span class='line'>208</span>  * @returns {string} the formatted date.
<span class='line'>209</span>  */</span><span class="WHIT">
<span class='line'>210</span> </span><span class="NAME">Date.prototype.format</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">format</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">  </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">n</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">format.replace</span><span class="PUNC">(</span><span class="REGX">/%[a-zA-Z0-9]/g</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">      </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%a'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">            </span><span class="STRN">"Sun"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Mon"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Tue"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Wed"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Thu"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Fri"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Sat"</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">          </span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">d.getDay</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%A'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">            </span><span class="STRN">"Sunday"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Monday"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Tuesday"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Wednesday"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Thursday"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Friday"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">            </span><span class="STRN">"Saturday"</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">          </span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">d.getDay</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%h'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%b'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>224</span> </span><span class="WHIT">            </span><span class="STRN">"Jan"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Feb"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Mar"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Apr"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"May"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Jun"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Jul"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Aug"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Sep"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>225</span> </span><span class="WHIT">            </span><span class="STRN">"Oct"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Nov"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Dec"</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">          </span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">d.getMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%B'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">            </span><span class="STRN">"January"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"February"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"March"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"April"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"May"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"June"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"July"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">            </span><span class="STRN">"August"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"September"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"October"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"November"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"December"</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT">          </span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">d.getMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%c'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d.toLocaleString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%C'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">Math.floor</span><span class="PUNC">(</span><span class="NAME">d.getFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%d'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%x'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%D'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">                  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">                  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%e'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">" "</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%H'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%I'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">12</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">12</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %j: day of year as a decimal number [001,366]</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%m'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%M'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%n'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"\n"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%p'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d.getHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">12</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"AM"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"PM"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%T'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%X'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%r'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">12</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">12</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">                  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">":"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">                  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">":"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">                  </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d.getHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">12</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"AM"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"PM"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%R'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">":"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%S'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%t'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"\t"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%u'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getDay</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">w</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %U: week number (sunday first day) [00,53]</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %V: week number (monday first day) [01,53] ... with weirdness</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%w'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d.getDay</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %W: week number (monday first day) [00,53] ... with weirdness</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%y'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">d.getFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">%</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%Y'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d.getFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">        </span><span class="COMM">// TODO %Z: timezone name or abbreviation</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'%%'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"%"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>278</span> </span></pre></body></html>